<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let UserFactory = function(role) {
            function SuperAdmin() {
                this.name = '超级管理员';
                this.viewPage = ['首页', '通讯录', '发现页', '应用数据', '权限管理']
            }

            function Admin() {
                this.name = '管理员';
                this.viewPage = ['首页', '通讯录', '发现页']
            }

            function NormalUser() {
                this.name = '普通用户';
                this.viewPage = ['首页', '通讯录', '发现页']
            }
            switch (role) {
                case 'superAdmin':
                    return new SuperAdmin();
                    break;
                case 'admin':
                    return new Admin();
            }
        }
    </script>
</body>

</html>